package com.pingtai.financial.action;

import com.pingtai.financial.entity.FinancialSearch;
import com.pingtai.financial.service.FinancialService;
import com.pingtai.user.entity.User;
import com.pingtai.user.service.UserManagerService;
import com.pingtai.util.PaginationSupport;

public class FinancialSituationAction {
	
	private UserManagerService userManagerService;
	private FinancialService financialService;
	private User curUser;
	private PaginationSupport paginationSupport;
	private FinancialSearch financialSearch;
	
	private int currentPage;
	private int pageNum;
	private String queryString;
	
	
	
	public User getCurUser() {
		return curUser;
	}
	public void setCurUser(User curUser) {
		this.curUser = curUser;
	}
	public PaginationSupport getPaginationSupport() {
		return paginationSupport;
	}
	public void setPaginationSupport(PaginationSupport paginationSupport) {
		this.paginationSupport = paginationSupport;
	}
	public FinancialSearch getFinancialSearch() {
		return financialSearch;
	}
	public void setFinancialSearch(FinancialSearch financialSearch) {
		this.financialSearch = financialSearch;
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	public String getQueryString() {
		return queryString;
	}
	public void setQueryString(String queryString) {
		this.queryString = queryString;
	}
	public UserManagerService getUserManagerService() {
		return userManagerService;
	}
	public void setUserManagerService(UserManagerService userManagerService) {
		this.userManagerService = userManagerService;
	}
	public FinancialService getFinancialService() {
		return financialService;
	}
	public void setFinancialService(FinancialService financialService) {
		this.financialService = financialService;
	}
	
	
	public String toConsumptionRecords(){
		curUser = userManagerService.findCurrectUser();
		if(currentPage>0) {
			pageNum = currentPage;
			currentPage = PaginationSupport.PAGESIZE*(currentPage-1);
		}
		
		paginationSupport = financialService.getFinancialRecords(currentPage,curUser);
		return "success";
	}
	
	private Integer type;
	
	
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	
	private String curUserId;
	
	
	public String getCurUserId() {
		return curUserId;
	}
	public void setCurUserId(String curUserId) {
		this.curUserId = curUserId;
	}
	public String showUserConsumptionRecords(){
		if(type==null) type=0; //收入支出混合  0 混合 1 收入  2 支出
		curUser = userManagerService.findUserById(Integer.parseInt(curUserId));
		if(currentPage>0) {
			pageNum = currentPage;
			currentPage = PaginationSupport.PAGESIZE*(currentPage-1);
		}
		if(type==0){
			paginationSupport = financialService.getFinancialRecords2(currentPage,curUser);
		}else if(type==1){
			paginationSupport = financialService.getFinancialRecords3(currentPage,curUser);
		}else if(type==2){
			paginationSupport = financialService.getFinancialRecords4(currentPage,curUser);
		}
		
		return "success";
	}

}
